package ncku.account.gui.old;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import ncku.account.gui.tableFactory;

public class showCategory{
    JFrame frame = new JFrame ("show Category");    
    
    public showCategory() {
    	frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add (BorderLayout.CENTER,new setUpGUI());
        frame.pack();
        frame.setLocation(300, 150);
        frame.setSize(500,300);
        frame.setVisible (true);
    }
    
    
    class setUpGUI extends JPanel{
		//介面上的元件
		private JLabel JLCategory;
	    private JComboBox categorySel;
	    private JButton JBNew;
	    private JButton JBEdit;
	    private JButton JBDelete;
	    
	    //Transaction
	    private tableFactory table;
	   
	    public setUpGUI(){
			String [] categorySelItems = {"Item 1", "Item 2", "Item 3"};  //category list
			Object [] [] CategoryItems = new Object [10][2];  //顯示在下方Table的SubTransaction object
			String [] columnItems = {" ","Name"};  //Category Table的項目
			
	        //construct components
			JLCategory = new JLabel("Category");
			categorySel = new JComboBox (categorySelItems);
			JBNew = new JButton("New");
			JBEdit = new JButton("Edit");
			JBDelete = new JButton("Delete");
			
			tableFactory table = new tableFactory(columnItems,CategoryItems);
	        table.setOpaque(true); //content panes must be opaque
	        
	        JLCategory.setVisible(true);
	        JBEdit.setVisible(true);
	        JBDelete.setVisible(true);
	        
	        //按下New後的Listener
	        JBNew.addActionListener(new ActionListener() { 
				public void actionPerformed(ActionEvent e) 
				{ 
					categoryFunction categoryNew = new categoryFunction("");
				}}); 
	
	        //按下Edit後的Listener
	        JBEdit.addActionListener(new ActionListener() { 
				public void actionPerformed(ActionEvent e) 
				{ 
					
				}}); 
	
	        //按下Delete後的Listener
	            JBDelete.addActionListener(new ActionListener() { 
	    			public void actionPerformed(ActionEvent e) 
	    			{ 
	    				
	    			}}); 
	        
	        //adjust size and set layout
	        setPreferredSize (new Dimension (681, 422));
	        setLayout (null);
	
	        //add components
	        add(categorySel);  //不知名bug,不add這個物件,table會莫名其妙跑不出來
	        add(JLCategory);
	        add(JBNew);
	        add(JBEdit);
	        add(JBDelete);
	        
	        add(table);
	
	        //setBounds(50, 125, 80, 30); //(X座標,Y座標,元件寬,元件高)
	        //set component bounds (only needed by Absolute Positioning)
	        JLCategory.setBounds(25, 20, 100, 25);
	        JBNew.setBounds(100,20,80,30);
	        JBEdit.setBounds(200,20,80,30);
	        JBDelete.setBounds(300,20,80,30);
	        table.setBounds(100,80,200,100);
	    }
    }
}
